package com.elsa.smart_buffet.service.impl;

import com.elsa.smart_buffet.mapper.MonthMapper;
import com.elsa.smart_buffet.mapper.MonthMenuMapper;
import com.elsa.smart_buffet.pojo.ResultBox.CallBackMessage;
import com.elsa.smart_buffet.pojo.ResultBox.ResponseResult;
import com.elsa.smart_buffet.service.MonthService;
import com.elsa.smart_buffet.utils.DateUtil;
import com.elsa.smart_buffet.utils.TimeUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @ClassName : MonthServiceImpl  //类名
 * @Author : elsa //作者
 */
@Service
@Slf4j
@Transactional
public class MonthServiceImpl implements MonthService {

    @Autowired
    private MonthMapper monthMapper;

    @Autowired
    private MonthMenuMapper monthMenuMapper;

    @Autowired
    private TimeUtil timeUtil;

    @Override
    public ResponseResult getMonthIncomeAndExpend() {
        int month = timeUtil.getMonthTime();
        return new ResponseResult(CallBackMessage.SUCCESS, monthMapper.selectById(month));
    }

    @Override
    public ResponseResult getMonthTopSale() {
        String month = String.valueOf(timeUtil.getMonthTime());
        return new ResponseResult(CallBackMessage.SUCCESS, monthMenuMapper.getMonthTopSale(month));
    }
}
